﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace CoreLib
{
    /// <summary>
    /// 读取拓普康数据类
    /// </summary>
    public class ReadTopoFileClass
    {
        /// <summary>
        /// 读取以SSS类型导出的坐标数据
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public static List<string> ReadSSSTopoFile(string fileName)
        {
            List<string> rtn = new List<string>();

            FileStream aFile = new FileStream(fileName, FileMode.Open);
            StreamReader sr = new StreamReader(aFile);
            string strLine = sr.ReadLine();

            while (strLine != null)
            {
                string row = strLine;
                string[] tmpRow = row.Trim().Split(',');

                //条件限定
                if (tmpRow == null || tmpRow.Length < 4)
                {
                    strLine = sr.ReadLine();
                    continue;
                }
                try
                {
                    Convert.ToDouble(tmpRow[1].Trim());
                    Convert.ToDouble(tmpRow[2].Trim());
                }
                catch
                {
                    strLine = sr.ReadLine();
                    continue;
                }
                string tmp = tmpRow[0].Trim() + "," + tmpRow[1] + "," + tmpRow[2] + "," + tmpRow[3].Trim();
                rtn.Add(tmp);
                strLine = sr.ReadLine();
            }
            return rtn;
        }

        /// <summary>
        /// 读取以GTS类型导出的坐标数据
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public static List<string> ReadGTSTopoFile(string fileName)
        {
            List<string> rtn = new List<string>();

            return rtn;
        }
    }
}
